import axios from "../../http/axios.js"
import {
  apiSignOut,
  apiWorkerSignOut
} from "../../http/server.js"

// 切换身份信息
export function switchInfo() {
  axios({
    url: apiSignOut,
    data: {
      openid: wx.getStorageSync("userInfo").openid
    }
  }).then(res => {
    wx.setStorageSync("userInfo", {})
    wx.reLaunch({
      url: "/pages/index/index",
    })
  })
}

// 职工退出登录
export function workerSignOut() {
  let userInfo = wx.getStorageSync("userInfo");
  let workersId = userInfo.workersId
  axios({
    url: `${apiWorkerSignOut}/${workersId}`,
    method: "PUT",
  }).then(res => {
    wx.setStorageSync("userInfo", {
      openid: userInfo.openid
    })
    wx.reLaunch({
      url: "/pages/n_login/n_login",
    })
  })
}